home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 11105 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.7 KB

  1. Path: zilker.net!usenet
  2. From: gregor@di3270.com (Greg Rickard)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: private base class vs. private member object
  5. Date: 12 Mar 1996 18:45:04 GMT
  6. Organization: Data Interface Systems Corporation
  7. Message-ID: <4i4gng$5v4@hackberry.zilker.net>
  8. Reply-To: di@di3270.com
  9. NNTP-Posting-Host: dp9.zilker.net
  10. X-Newsreader: WinVN 0.91.6
  11.  
  12. Certainly to be able to access the protected methods of another class, 
  13. that class must be incorporated as a base class.
  14. Now what about the case where a service MUST be incorporated as a private 
  15. member object (i.e., CANNOT be incorporated as a base class)?
  16.  
  17. >gregor@di3270.com (Greg Rickard) wrote:
  18. >>In Cargill's C++ Programming Style, exercise 3.1 asks the reader to 
  19. >>"create a class that obtains the services of another class that must be 
  20. >>incorporated as a private base class.  Second, create a class in which a 
  21. >>service must be incorporated as a private member object".
  22.  
  23. In article <4hrl32$4b3@newsgate.dircon.co.uk>, Rob and Sylvia Worsnop 
  24. <gillesp@dircon.co.uk> says:
  25. >
  26. >I'm not sure quite what you mean here so there is a risk that I'll
  27. >be answering a question you've not even asked! Anyway , here goes..
  28. >
  29. >If you are asking when to use private base classes and when to use a 
  30. >private member object, the answer is that you can use private member 
  31. >object only when you can do everything you want with that object's
  32. >public interface. 
  33. >If you want to access protected methods use private inheritance. 
  34. >Some people just use private inheritance anyway because the code 
  35. >is often cleaner.
  36. >Whether you use private member objects or private inheritance doesn't
  37. >matter a great deal. The really important thing is not to confuse 
  38. >public inheritance and private inheritance.
  39. >
  40. >Rob.
  41.